<%--
  Created by IntelliJ IDEA.
  User: 98248
  Date: 2020/10/12
  Time: 14:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery.js"></script>
</head>
<body>
    <div>
        <form action="" method="post">
            卡号：<input type="text" name="cardNo" id="cardNo"/><br/>
            密码：<input type="password" name="passWord" id="passWord"/><br/>
            <input type="button" id="btn" value="登录网上银行">
        </form>
    </div>
<script type="text/javascript">
    $(function(){
        $("#btn").click(function () {
            var cardNo = $("#cardNo").val();
            var pwd = $("#passWord").val();
            if(cardNo.length!=16){
                alert("卡号必须为16位");
                return;
            }
            if (pwd.length!=6){
                alert("请正确填写6位登录密码");
            }

            $.ajax({
                url:"${pageContext.request.contextPath }/doLogin",
                type:"post",
                data:{
                    "cardNo":cardNo,
                    "passWord":pwd
                },
                dataType:"json",
                success:function (res) {
                    if(res==true){
                        alert("登录成功！！");
                        window.location.href="main";
                    }else{
                        alert("登录失败");
                        window.location.href="${pageContext.request.contextPath }/login";
                    }
                }
            })
        })
    })
</script>
</body>
</html>
